package org.example.lease.web.app.controller.room;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.lease.common.result.Result;
import org.example.lease.web.app.service.RoomInfoService;
import org.example.lease.web.app.vo.room.RoomDetailVo;
import org.example.lease.web.app.vo.room.RoomItemVo;
import org.example.lease.web.app.vo.room.RoomQueryVo;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "根据条件查询房间分页列表")
@RestController
@RequestMapping("/app/room")
public class RoomController {

    @Autowired
    private RoomInfoService roomInfoService;

    @Operation(summary = "根据条件分页查询房间列表")
    @GetMapping("pageItem")
    public Result<IPage<RoomItemVo>> pageItem(@RequestParam Long current, @RequestParam Long size,@ParameterObject RoomQueryVo queryVo){
        IPage<RoomItemVo> page=new Page<>(current,size);
        IPage<RoomItemVo> result=roomInfoService.pageRoomItemByQuery(page,queryVo);
        return Result.ok(result);
    }

    @Operation(summary = "根据id查询房间详情")
    @GetMapping("getDetailById")
    public Result<RoomDetailVo> getDetailById(@RequestParam Long id){
        RoomDetailVo result=roomInfoService.getRoomDetailById(id);
        return Result.ok(result);
    }

    @Operation(summary = "根据公寓id分页查询房间列表")
    @GetMapping("pageItemByApartmentId")
    public Result<IPage<RoomItemVo>> pageItemByApartmentId(@RequestParam Long current,
           @RequestParam Long size,@RequestParam Long apartmentId){
        IPage<RoomItemVo> page=new Page<>(current,size);
        IPage<RoomItemVo> list=roomInfoService.pageRoomItemByApartmentId(page,apartmentId);
        return Result.ok(list);
    }

}





























